<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>搜索分析- 关键词分析</title>
<meta name="description" content="overview &amp; stats" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

<link rel="stylesheet"  href="${request.contextPath}/assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="${request.contextPath}/assets/font-awesome/4.2.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="${request.contextPath}/assets/css/jquery-ui.custom.min.css" />
<link rel="stylesheet" href="${request.contextPath}/assets/css/jquery.gritter.min.css" />
<link rel="stylesheet" href="${request.contextPath}/assets/fonts/fonts.googleapis.com.css" />
<link rel="stylesheet" href="${request.contextPath}/assets/css/bootstrapValidator.min.css" />
<link rel="stylesheet" href="${request.contextPath}/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
<link rel="stylesheet" href="${request.contextPath}/assets/css/bsie-paginator.css" />
<link rel="stylesheet"  href="${request.contextPath}/stylesheets/daterangepicker.css">
<link rel="stylesheet" href="${request.contextPath}/stylesheets/loading.css" />
<link rel="stylesheet" href="${request.contextPath}/stylesheets/tips.css"/>
</head>
<style>
 tr,th{text-align: center;}
 thead tr{height:38px;}
 thead th{min-width:100px;}
 .pointTabForKey tr{height:38px;}
 .pointTabForCategory tr{height:38px;}
 a:hover{color:blue;text-decoration: none;}
.stat.stat-important:after {bottom: -27px !important;}
.modal-dialog{    
	position:fixed;
	width:850px;
	height:100%;
 }
</style>
<body class="no-skin" style="background-color: #FFF;">
	<div class="page-content">
		<div class="tabbable">
			<ul class="nav nav-tabs" id="myTab">
				<li class="active"><a data-toggle="tab" href="#" aria-expanded="false"  onclick="changeTab(1)">关键词分析 </a></li>
				<li class=""><a data-toggle="tab" href="#" aria-expanded="true" onclick="changeTab(2)"> 关键词到达品类分析</a></li>
			</ul>

			<div class="tab-content" id="keywordDiv1">
				<div id="manage" class="tab-pane active in">
					<div class="row">
						<div class="col-xs-12">
						<!-- 筛选条件开始 -->
							<div class="row">
								<div class="col-xs-12">
									<div class="widget-box">
										<div class="widget-header widget-header-small">
											<h4 class="widget-title">关键词类型分析(PV)</h4>
										</div>
										<div class="widget-body" style="background-color: #EFF3F8;">
											<div class="widget-main">
												<form class="form-inline" id="searchForm" method="post" action="#">
                                                    <div class="form-group">
														<label for="exampleInputName2">选择时段
															<input type="text" id="config-demo" name="chooseTime" id="chooseTime" class="form-control time">
															<button id="app_search" type="button"  onclick="replaceDate(this,'1');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																昨日
															</button>
															<button id="app_search" type="button"  onclick="replaceDate(this,'7');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																过去7天
															</button>
															<button id="app_search" type="button"  onclick="replaceDate(this,'31');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																过去31天
															</button>
														</label>
														<label for="exampleInputName" style="margin-left: 30px;">分站：
															<select class="chosen-select" tabindex="2"  name="station_id" id="station_id" style="width:80px;">
																  <option value="0">全部</option>
																 <#if stationList?? && stationList?size&gt;0>
																	 <#list stationList as item>
																		<option value="${item.stationId}" <#if item.stationName == '上海'>selected</#if> >${item.stationName}</option>
																	 </#list>
																 </#if>
															</select>
														</label>
														<label for="exampleInputName" style="margin-left: 30px;">平台：
															<select class="chosen-select" tabindex="2" name="platform_code" id="platform_code" style="width:80px;">
																<option value="">全部</option>
																<!-- <option value="pc">PC</option> -->
																<option value="app">APP</option>
																<option value="wap">WAP</option>
															</select>
														</label>
														
														<button id="search" type="button" class="btn btn-pink btn-sm"  style="margin-left: 50px;">
															<span class="ace-icon fa fa-search icon-on-right bigger-110"></span> Search
														</button>
													</div>
												</form>
											</div>
										</div>
									</div>
								</div>
							</div>
							<!-- 筛选条件结束 -->
							<div class="row">
								<div class="col-sm-6">
									<div class="widget-box">
										<div class="widget-header widget-header-flat">
											<h4 class="widget-title lighter">
												<i class="ace-icon fa fa-signal  blue"></i>关键词类型点击量趋式
											</h4>
											<label class="help_img">
												<i class="blue ace-icon fa fa-question-circle bigger-120" style="color:#999999!important;"></i>
												<span class='tips'>一段时间内搜索关键词各点击类型逐日的PV量<s></s></span>
											</label>
											<!-- <span class="label label-lg label-purple arrowed" style="float:right;margin-top:5px;margin-right:10px;padding: 6px;" id="exportDetailKeywordTrend" onclick="exportCsv2('1');">导出</span> -->
										</div>
										<div class="widget-header widget-header-small">
											<div id="tendency-chart" style="height: 400px;"></div>
										</div>
									</div>
								</div>
								<div class="col-sm-6"  style="padding-left: 0px!important;">
										<div  class="widget-box">
											<div class="widget-header widget-header-flat">
												<h4 class="widget-title lighter">
													<i class="ace-icon fa fa-star orange"></i>关键词类型点击量统计
												</h4>
												<label class="help_img">
													<i class="blue ace-icon fa fa-question-circle bigger-120" style="color:#999999!important;"></i>
													<span class='tips'>一段时间内搜索关键词各点击类型的总PV量<s></s></span>
												</label>
												<!-- <span class="label label-lg label-purple arrowed" style="float:right;margin-top:5px;margin-right:10px;padding: 6px;" id="exportDetailKeywordStatistic" onclick="exportCsv2('2');">导出</span>-->
											</div>
											<div class="widget-header widget-header-small">
												<div id="statistical-chart" style="height: 400px;"></div>
											</div>
										</div>
									</div>
							  </div>
							
							<div class="row">
								<div class="col-xs-12">
									<div class="widget-box">
										<div class="widget-header widget-header-small">
											<h4 class="widget-title">关键词详情
											<label class="help_img">
												<i class="blue ace-icon fa fa-question-circle bigger-120" style="color:#999999!important;"></i>
												<span class='tips'>一段时间内各分站搜索关键词的搜索次数，并分别对某一关键词两个维度（搜索点击类型和用户所在区域）搜索次数进行展现<s></s></span>
											</label>
											</h4>
										</div>
										<div class="widget-body" style="background-color: #EFF3F8;">
											<div class="widget-main">
												<form class="form-inline" id="searchForm" method="post"
													action="#">
													<div class="form-group">
														<label for="exampleInputName2">选择时段
															<input type="text" id="config-demo2" name="chooseTime" class="form-control time">
															<button  type="button"  onclick="replaceDate(this,'1');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																昨日
															</button>
															<button  type="button"  onclick="replaceDate(this,'7');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																过去7天
															</button>
															<button  type="button"  onclick="replaceDate(this,'31');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																过去31天
															</button>
														</label> 
														
														<label for="exampleInputName" style="margin-left: 30px;">分站：
															<select class="chosen-select" tabindex="2"  name="stationForKey" id="stationForKey" style="width:80px;">
																 <option value="0">全部</option>
																 <#if stationList?? && stationList?size&gt;0>
																	 <#list stationList as item>
																		<option value="${item.stationId}" <#if item.stationName == '上海'>selected</#if> >${item.stationName}</option>
																	 </#list>
																 </#if>
															</select>
														</label>
														
														<label for="exampleInputName" style="margin-left: 30px;">搜索次数：
															<label><input type="checkbox" name="searchSetion" value="1" checked>小于50</label>
															<label style="padding-left: 10px;"><input type="checkbox" name="searchSetion"  value="2" checked>50-500</label>
															<label style="padding-left: 10px;"><input type="checkbox" name="searchSetion" value="3" checked>500-1000</label>
															<label style="padding-left: 10px;"><input type="checkbox"  name="searchSetion" value="4" checked>大于1000</label>
														</label>
														
														<button id="searchKeyWord" type="button" class="btn btn-pink btn-sm"  style="margin-left: 30px;">
															<span class="ace-icon fa fa-search icon-on-right bigger-110"></span> Search
														</button>
													</div>
												</form>
											</div>
										</div>
									</div>
								</div>
						  	 </div>
							  <div class="row">
								<div class="col-xs-6">
									<div class="widget-box transparent">
										<div>
											<div class="widget-main no-padding" id="keywordtab">
												<table class="dataTable table table-bordered table-striped">
													<thead class="thin-border-bottom">
														<tr>
															<th>序号 </th>
															<th> 关键词</th>
															<th class="sorting"  onclick="changeFlag(this)">
																搜索次数（PV）
															    <input type="hidden" value="2" id="flag"/>
															</th>
														</tr>
													</thead>
													<tbody class="pointTabForKey"> </tbody>
												</table>
												
												<div class="ui-jqgrid">
													<div id="grid-pager"
														class="ui-state-default ui-jqgrid-pager ui-corner-bottom"
														dir="ltr">
														<div id="pg_grid-pager" class="ui-pager-control" role="group">
															<input type="text" id="currentPage" hidden="true" value=1>
															<input type="text" id="page_size" value =15 hidden="true">
															<input type="text" id="page_total" hidden="true">
															<table cellspacing="0" cellpadding="0" border="0"
																class="ui-pg-table"
																style="width: 100%; table-layout: fixed; height: 100%;"
																role="row">
																<tbody>
																	<tr>
																		<td id="grid-pager_left" align="left"></td>
																		<td id="grid-pager_center" align="center"
																			style="white-space: pre; width: 343px;"><table
																				cellspacing="0" cellpadding="0" border="0"
																				style="table-layout: auto;" class="ui-pg-table">
																				<tbody>
																					<tr>
																						<td id="first_grid-pager"
																							onclick="showPage('firstPage')"
																							class="ui-pg-button ui-corner-all "
																							style="cursor: pointer;"><span
																							class="ui-icon ace-icon fa fa-angle-double-left bigger-140"></span></td>
																						<td id="prev_grid-pager"
																							onclick="showPage('prePage')"
																							class="ui-pg-button ui-corner-all "
																							style="cursor: pointer;"><span
																							class="ui-icon ace-icon fa fa-angle-left bigger-140"></span></td>
																						<td dir="ltr">Page <input class="ui-pg-input" id="page_num"
																							type="text" size="2" maxlength="7" disabled="true" 
																							value="" role="textbox"> of <span
																							id="sp_1_grid-pager"></span></td>
																						<td id="next_grid-pager"
																							onclick="showPage('nextPage')"
																							class="ui-pg-button ui-corner-all "
																							style="cursor: pointer;"><span
																							class="ui-icon ace-icon fa fa-angle-right bigger-140"></span></td>
																						<td id="last_grid-pager"
																							onclick="showPage('lastPage')"
																							class="ui-pg-button ui-corner-all "
																							style="cursor: pointer;"><span
																							class="ui-icon ace-icon fa fa-angle-double-right bigger-140"></span></td>
																					</tr>
																				</tbody>
																			</table></td>
																			
																		<td id="grid-pager_right" align="right">
																				<div dir="ltr" style="text-align: right" class="ui-paging-info">View
																					<span id="view_start_row"></span> - <span id="view_end_row"></span> 
																					of <span id="view_page_total"></span>
																				</div>
																		</td>
																	</tr>
																</tbody>
															</table>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="col-xs-6" style="display:none;padding-left: 0px!important;" id="detailDiv">
									<div class="widget-box transparent">
										<div class="widget-body">
											<div class="widget-main no-padding">
												<div class="widget-header widget-header-flat">
													<h4 class="widget-title lighter">
														<i class="ace-icon fa fa-star orange"></i><span class="keyWordName"></span>
														<label style="margin-left: 20px;font-size: 12px;" class="keyWordSection"></label>
														<label style="float: right;padding-right: 5px;font-size: 12px;">关键词类型分布</label>
													</h4>
												</div>
												<div class="widget-header widget-header-small">
													<div id="detail-chart" style="height: 258px;"></div>
												</div>
											</div>
									   </div>
									</div>
									
									<div class="widget-box transparent">
										<div class="widget-body">
											<div class="widget-main no-padding">
												<div class="widget-header widget-header-flat">
													<h4 class="widget-title lighter">
														<i class="ace-icon fa fa-star orange"></i><span class="keyWordName"></span> 
														<label style="margin-left: 20px;font-size: 12px;" class="keyWordSection"></label>
														<label style="float: right;padding-right: 5px;font-size: 12px;">用户所在地区域前十名</label>
														<!-- <span class="label label-lg label-purple arrowed" style="float:right;margin-top:5px;margin-right:10px;padding: 6px;" id="exportDetailTop10" onclick="exportKeywordAnalasys('2');">导出</span> -->
													</h4>
												</div>
												<div class="widget-header widget-header-small">
													<div id="place-chart" style="height: 310px;"></div>
												</div>
											</div>
									   </div>
									</div>
							  </div>
						  </div>
						</div>
					</div>
					</div>
					</div>
			
		<input type="hidden" id="axis" value=""/>
		<!-- 弹窗	 -->
		<div class="row">
			<div class="col-xs-12">
				<button class="btn btn-info" data-toggle="modal" type="button" style="display:none;" id="update" data-target="#myModal"></button>
					<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
						 aria-labelledby="myModalLabel" aria-hidden="true">
						<div class="modal-dialog" id="modal-dialog">
							<div class="modal-content">
								<div id="chartMore">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
										<h4 class="modal-title" id="funnelLabel">用户所在地区域分布</h4>
									</div>
									<div class="modal-body">
										<div class="widget-box">
											<div class="widget-header widget-header-small">
												<div id="place-chart-all"  style="width: 850px; height: 850px;"></div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
			</div>
		 </div>
		</div>
		
		<div class="tab-content" id="keywordDiv2" style="display: none;">
				<div id="manage2" class="tab-pane active in">
					<div class="row">
						<div class="col-xs-12">
						<!-- 筛选条件开始 -->
							<div class="row">
								<div class="col-xs-12">
									<div class="widget-box">
										<div class="widget-header widget-header-small">
											<h4 class="widget-title">关键词搜索品类详情(PV)</h4>
										</div>
										<div class="widget-body" style="background-color: #EFF3F8;">
											<div class="widget-main">
												<form class="form-inline" id="searchForm2" method="post" action="#">
													<div class="form-group">
														<label for="exampleInputName2">选择时段
															<input type="text" id="config-demo3" name="chooseTime" class="form-control time">
															<button  type="button"  onclick="replaceDate(this,'1');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																昨日
															</button>
															<button  type="button"  onclick="replaceDate(this,'7');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																过去7天
															</button>
															<button  type="button"  onclick="replaceDate(this,'31');" class="btn btn-white btn-sm">
																<span class="ace-icon icon-on-right bigger-110"></span>
																过去31天
															</button>
														</label>
														<label for="exampleInputName" style="margin-left: 30px;">分站：
															<select class="chosen-select" tabindex="2"  name="stationForCategory" id="stationForCategory" style="width:80px;">
																 <option value="0">全部</option>
																 <#if stationList?? && stationList?size&gt;0>
																	 <#list stationList as item>
																		<option value="${item.stationId}" <#if item.stationName == '上海'>selected</#if> >${item.stationName}</option>
																	 </#list>
																 </#if>
															</select>
														</label>
														
														<label for="exampleInputName" style="margin-left: 30px;">平台：
															<select class="chosen-select" tabindex="2" name="platform_code3" id="platform_code3" style="width:80px;">
																<option value="">全部</option>
																<!-- <option value="pc">PC</option> -->
																<option value="app">APP</option>
																<option value="wap">WAP</option>
															</select>
														</label>
														
														<button id="search2" type="button" class="btn btn-pink btn-sm"  style="margin-left: 50px;">
															<span class="ace-icon fa fa-search icon-on-right bigger-110"></span> Search
														</button>
													</div>
												</form>
											</div>
										</div>
									</div>
								</div>
							</div>
							<!-- 筛选条件结束 -->
							
							<div class="row">
								<div class="col-xs-12">
									<div class="widget-box">
										<div class="widget-header widget-header-flat">
											<h4 class="widget-title lighter">
												<i class="ace-icon fa fa-signal blue"></i>关键词搜索到达品类分析
											</h4>
											<span style="font-size: 10px;">(视图可点击！！)</span>
											<label class="help_img">
												<i class="blue ace-icon fa fa-question-circle bigger-120" style="color:#999999!important;"></i>
												<span class='tips'>一段时间内搜索到达各品类的PV总量<s></s></span>
											</label>
										</div>
										<div class="widget-header widget-header-small">
											<div id="statistical-chart2" style="height: 400px;"></div>
										</div>
									</div>
								</div>
							</div>
							
							<div class="row"  id="searchKeyDetail" style="display: none;">
								<div class="col-xs-6">
									<div class="widget-box transparent">
										<div class="widget-body">
											<div class="widget-main no-padding">
												<div class="widget-header widget-header-flat">
													<h4 class="widget-title lighter">
														<i class="ace-icon fa fa-star orange"></i><label id="categoryName"></label>&nbsp;&nbsp;搜索词前十名
														<label style="margin-left: 20px;font-size: 12px;" class="dateSection"></label>
													</h4>
													<span style="font-size: 10px;">(视图可点击！！)</span>
													<label class="help_img">
														<i class="blue ace-icon fa fa-question-circle bigger-120" style="color:#999999!important;"></i>
														<span class='tips'>某一品类搜索次数排名前十的搜索关键词详情（点击品类柱子获取该图形）<s></s></span>
													</label>
													
												</div>
												<div class="widget-header widget-header-small">
													<div id="place-chart2" style="height: 450px;"></div>
												</div>
											</div>
									   </div>
									</div>
							     </div>
							     
							     <div class="col-xs-6" id="productDetail" style="display: none;padding-left: 0px!important;">
										<div class="widget-box transparent">
											<div class="">
												<div class="widget-main no-padding">
													<div class="widget-header widget-header-flat">
														<h4 class="widget-title lighter">
															<i class="ace-icon fa fa-star orange"></i><span id="keywordNum"></span></b>  
															<label style="margin-left: 20px;" class="dateSection"></label>
														</h4>
														<label class="help_img">
															<i class="blue ace-icon fa fa-question-circle bigger-120" style="color:#999999!important;"></i>
															<span class='tips'>某一品类关键词搜索结果中各产品的出现次数（点击左侧关键词获取相关关键词搜索的相关产品的信息）<s></s></span>
														</label>
														
													</div>
													<table class="dataTable table table-bordered table-striped">
														<thead class="thin-border-bottom">
															<tr>
																<th>产品ID</th>
																<th>产品名称</th>
																<th class="sorting"  onclick="changeFlag2(this)">
																	搜索次数（PV）
																	<input type="hidden" value="2" id="flag2"/>
																</th>
															</tr>
														</thead>
														<tbody class="pointTabForCategory"></tbody>
													</table>
													
													<div class="ui-jqgrid2">
														<div id="grid-pager2"
															class="ui-state-default ui-jqgrid-pager ui-corner-bottom"
															dir="ltr">
															<div id="pg_grid-pager2" class="ui-pager-control" role="group">
															    <input type="hidden" id="keyword" >
																<input type="hidden" id="keyword_value">
																<input type="hidden" id="currentPage2" value="1">
																<input type="hidden" id="page_size2" value ="10" >
																<input type="hidden" id="page_total2" hidden="true">
																<table cellspacing="0" cellpadding="0" border="0"
																	class="ui-pg-table"
																	style="width: 100%; table-layout: fixed; height: 100%;"
																	role="row">
																	<tbody>
																		<tr>
																			<td id="grid-pager_left2" align="left"></td>
																			<td id="grid-pager_center2" align="center"
																				style="white-space: pre; width: 343px;"><table
																					cellspacing="0" cellpadding="0" border="0"
																					style="table-layout: auto;" class="ui-pg-table">
																					<tbody>
																						<tr>
																							<td id="first_grid-pager2"
																								onclick="showPage2('firstPage')"
																								class="ui-pg-button ui-corner-all "
																								style="cursor: pointer;"><span
																								class="ui-icon ace-icon fa fa-angle-double-left bigger-140"></span></td>
																							<td id="prev_grid-pager2"
																								onclick="showPage2('prePage')"
																								class="ui-pg-button ui-corner-all "
																								style="cursor: pointer;"><span
																								class="ui-icon ace-icon fa fa-angle-left bigger-140"></span></td>
																							<td dir="ltr">Page <input class="ui-pg-input" id="page_num2"
																								type="text" size="2" maxlength="7" disabled 
																								 role="textbox"> of <span
																								id="sp_1_grid-pager2"></span></td>
																							<td id="next_grid-pager2"
																								onclick="showPage2('nextPage')"
																								class="ui-pg-button ui-corner-all "
																								style="cursor: pointer;"><span
																								class="ui-icon ace-icon fa fa-angle-right bigger-140"></span></td>
																							<td id="last_grid-pager2"
																								onclick="showPage2('lastPage')"
																								class="ui-pg-button ui-corner-all "
																								style="cursor: pointer;"><span
																								class="ui-icon ace-icon fa fa-angle-double-right bigger-140"></span></td>
																						</tr>
																					</tbody>
																				</table></td>
																				
																			<td id="grid-pager_right" align="right">
																					<div dir="ltr" style="text-align: right" class="ui-paging-info">View
																						<span id="view_start_row2"></span> - <span id="view_end_row2"></span> 
																						of <span id="view_page_total2"></span>
																					</div>
																			</td>
																		</tr>
																	</tbody>
																</table>
															</div>
														</div>
													</div>
													
												</div>
											</div>
										</div>
									</div>
							  </div>
						</div>
					</div>
				</div>
			</div>
		</div>

	<script src="${request.contextPath}/assets/js/jquery.2.1.1.min.js"></script>
	<script src="${request.contextPath}/assets/js/bootstrap.min.js"></script>
	<script src="${request.contextPath}/assets/js/jquery-ui.custom.min.js"></script>
	<script src="${request.contextPath}/assets/js/jquery.ui.touch-punch.min.js"></script>
	<script src="${request.contextPath}/assets/js/bootbox.min.js"></script>
	<script src="${request.contextPath}/assets/js/jquery.gritter.min.js"></script>
	<script src="${request.contextPath}/assets/js/spin.min.js"></script>
	<script src="${request.contextPath}/assets/js/ace-elements.min.js"></script>
	<script src="${request.contextPath}/assets/js/ace.min.js"></script>
	<script src="${request.contextPath}/assets/js/bootstrapValidator.min.js"></script>
	<script src="${request.contextPath}/assets/js/user/base.js"></script>
	<script src="${request.contextPath}/assets/js/ace-extra.min.js"></script>
	<script src="${request.contextPath}/assets/js/moment.min.js"></script>
	<script
		src="${request.contextPath}/assets/js/bootstrap-datetimepicker.min.js"></script>
	<script type="text/javascript"
		src="${request.contextPath}/javascripts/moment.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/daterangepicker.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/dateRange.js"></script>
	<script src="${request.contextPath}/assets/js/d3.v3.min.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/loading.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/g2.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/g2-modal.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/slider.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/FileSaver.js"></script>
	<script type="text/javascript" src="${request.contextPath}/javascripts/export-csv.js"></script>
	<script type="text/javascript">
	d3.select(self.frameElement).style("height", "1500px");
	$(document).ready(function(){
		getSearchDate();
		var currentPage=1;//当前页面
		var page_size=$("#page_size").val();//页面大小10条
		getSearchkeyWord(currentPage,page_size);
	});
	$("#search").on("click",function(){
		getSearchDate();
	});
	function getSearchDate(){
		var choose_date = $("#config-demo").val();
		var platform_code = $("#platform_code").val();
		var station_id =  $("#station_id").val();
		$.ajax({
			url : '${request.contextPath}/searchStatistic/keyAjaxData',
			type : "POST",
			data : {
				// choose_date:choose_date,
                beginDate:choose_date.split("-")[0]+" 00:00:00",
                endDate:choose_date.split("-")[1]+" 23:59:59",
				platformCode:platform_code,
				stationId:station_id
			},
			beforeSend: function(){
 			   $("#search").attr("disabled",true);
 			    openPartialLayer($("#statistical-chart"));
 			    openPartialLayer($("#tendency-chart"));
	    	 },
		    complete: function(){
		    	$("#search").attr("disabled",false);
		    	removeLoading($("#statistical-chart"));
		    	removeLoading($("#tendency-chart"));
		    },
			success:function(data) {

                if (data.code != 0){
                    return;
                }
                var data = data.data;
				var defs = {
						'category': {
							alias : '关键词类型'
						},
						'amount': {
							alias :'点击量（次）'
						},
						'time':{
							type: 'time',
							tickCount: 8
						}
					};

                    histogramModal(data.barData,'statistical-chart','category','amount','点击量（次）','关键词类型','400',defs);
                    lineChartModal(data.lineData,'tendency-chart','time','amount','category','','点击量（次）','400',defs);

			},
			error:function(data) {
				//showMsg("查询数据有误");
			}
		});
	}
	
	$("#searchKeyWord").on("click",function(){
		$("#flag").val(2);
		$("#flag2").val(2);
	    var currentPage=1;//当前页面
		var page_size=$("#page_size").val();//页面大小10条
		getSearchkeyWord(currentPage,page_size);
	});
	
	function changeFlag(obj){
		var sortName = $(obj).attr("class");
		var flag = $("#flag").val();
		var num;
		if(sortName == "sorting" || sortName == "sorting_asc"){
			$("#keywordtab .dataTable th").eq(2).attr("class","sorting_desc");
			num = 2;//降序
		}else if(sortName == "sorting_desc"){
			$("#keywordtab .dataTable th").eq(2).attr("class","sorting_asc");
			num = 1;
		}
		if(num != flag){
			$("#flag").val(num);
			var page_size=$("#page_size").val();
			getSearchkeyWord(1,page_size);
		}
	}
	
	function getSearchkeyWord(currentPage,page_size){
	    var flag = $("#flag").val();
		var choose_date = $("#config-demo2").val();
		var stationForKey =  $("#stationForKey").val();
		var obj=document.getElementsByName('searchSetion'); //返回数组 
		var sectionIds=''; 
		for(var i=0; i<obj.length; i++){ 
			if(obj[i].checked) 
			  sectionIds+=obj[i].value+','; //如果选中，将value添加到变量sectionIds中 
		}
		$.ajax({
			url : '${request.contextPath}/searchStatistic/keyWordAjaxData',
			type : "POST",
			data : {
				// choose_date:choose_date,
                beginDate:choose_date.split("-")[0]+" 00:00:00",
                endDate:choose_date.split("-")[1]+" 23:59:59",
				sectionIds:sectionIds,
				stationId:stationForKey,
                pageCurrentNum:currentPage,
				pageSize:page_size,
				flag:flag
			},
			beforeSend: function(){
				openPartialLayer($(".pointTabForKey"));
	    	 },
		    complete: function(){
				removeLoading($(".pointTabForKey"));
		    },
			success:function(data) {
			    var tbody = "";
			    var page = data.data;
				if(page && page.list  && page.list.length > 0){
			    	// var page=data.page;
			    	if(page.pages>1){
					    $("#page_total").val(page.pages);
				    	$("#currentPage").val(page.pageNum);
				    	$("#page_num").val(page.pageNum);
				    	$("#sp_1_grid-pager")[0].innerText=page.pages;
				    	$("#view_start_row")[0].innerText= page.startRow;
				    	$("#view_end_row")[0].innerText= page.endRow;
				    	$("#view_page_total")[0].innerText= page.total;
				    	$(".ui-jqgrid").show();
				    }else{
				    	$(".ui-jqgrid").hide();
				    }
			    	
			   		$.each(page.list,function(n,value) {   
				       tbody +=  "<tr onclick='showDetail(\""+value.keyWord +"\",\""+value.amount +"\",this)'>"+
									"<td>"+ (n+1) +"</td>"+
									"<td><small>"+value.keyWord +"</small></td>"+
									"<td class='hidden-480'>"+ value.amount +"</td>"+
								"</tr>";  
			       });
			   }else{
			   		var tbody='<tr><td colspan="12"><div class="alert alert-danger" style="margin-bottom: 0px;" role="alert">没有记录!</div></td></tr>';
			   		$(".ui-jqgrid").hide();
			   		$("#detailDiv").hide();
			   }
			    $(".pointTabForKey").html(tbody); 
			    $(".pointTabForKey").css("cursor","pointer");
			    $(".pointTabForKey tr:first-child").click(); 
			},
			error:function(data) {
				//showMsg("查询数据有误");
			}
		});
	}
	
	
	function showDetail(key_word,value,obj){
		    $("#detailDiv").hide();
        	$("#detailDiv").show();
   			$(".pointTabForKey tr").css("background-color","");
   			$(obj).css("background-color","#d9edf6");
   			getKeyDetail(key_word,value);
	}
	
	
	function getKeyDetail(key_word,value){
		var choose_date = $("#config-demo2").val();
		var stationForKey =  $("#stationForKey").val();
		
		$(".keyWordName").html(key_word);
		$(".keyWordSection").html(choose_date);
		var obj=document.getElementsByName('searchSetion'); //返回数组 
		var sectionIds=''; 
		for(var i=0; i<obj.length; i++){ 
			if(obj[i].checked) 
			  sectionIds+=obj[i].value+','; //如果选中，将value添加到变量sectionIds中 
		} 
		$.ajax({
			url : '${request.contextPath}/searchStatistic/typeAStationAjaxData',
			type : "POST",
			data : {
				// choose_date:choose_date,
                beginDate:choose_date.split("-")[0]+" 00:00:00",
                endDate:choose_date.split("-")[1]+" 23:59:59",
                sectionIds:sectionIds,
				stationId:stationForKey,
				keyWord:key_word
			},
			beforeSend: function(){
				openPartialLayer($("#detail-chart"));
				openPartialLayer($("#place-chart"));
	    	 },
		    complete: function(){
				removeLoading($("#detail-chart"));
				removeLoading($("#place-chart"));
		    },
			success:function(data) {
			    if(data && data.code!=0){
			        return;
				}
			    var data = data.data;
				if(data.flag == "true"){
					//$("#axis").val(data.stationAllData);
					$("#moreFlag").show();
				}else{
					$("#moreFlag").hide();
				}
				var defs1 = {
						'category': {
							alias : '关键词类型'
						},
						'amount': {
							alias :'点击量（次）'
						}
					};
				var defs2 = {
					'category': {
						alias : '地区'
					},
					'amount': {
						alias :'点击量（次）'
					}
				};
	   			horizontalHistogramModal(data.keyData,'detail-chart','category','amount',258,defs1);
	   			horizontalHistogramModal(data.stationData,'place-chart','category','amount',310,defs2);
			},
			error:function(data) {
				showMsg("查询数据有误");
			}
		});
	}
	
	function getMoreData(){ 
		//展示遮罩层
		$("#update").click();
		center($("#modal-dialog"));
		//滚动到顶部
		//$('html,body').animate({scrollTop:"0px"},1000);alert($("#axis").val());
		//显示数据
		setTimeout(function(){
			var values = ($("#axis").val()).split(",");
			horizontalHistogramModal(values,'place-chart-all','category','amount',800);
		},1000)
	}
	
	
	function center(obj) {
	    var screenWidth = $(window).width(), screenHeight = $(window).height();  //当前浏览器窗口的 宽高
	    var scrolltop = $(document).scrollTop(); //获取当前窗口距离页面顶部高度
	    var objLeft = (screenWidth - obj.width())/2 ;
	    var objTop = (screenHeight - obj.height())/2 + scrolltop;
	    obj.css({left: objLeft + 'px', top: objTop + 'px','display': 'block'});
	    //浏览器窗口大小改变时
	    $(window).resize(function() {
	        screenWidth = $(window).width();
	        screenHeight = $(window).height();
	        scrolltop = $(document).scrollTop();
	        objLeft = (screenWidth - obj.width())/2 ;
	        objTop = (screenHeight - obj.height())/2 + scrolltop;
	
	        obj.css({left: objLeft + 'px', top: objTop + 'px'});
	    });
	    
	     //浏览器有滚动条时的操作、
	    $(window).scroll(function() {
	        screenWidth = $(window).width();
	        screenHeight = $(window).height();
	        scrolltop = $(document).scrollTop();
	        objLeft = (screenWidth - obj.width())/2 ;
	        objTop = (screenHeight - obj.height())/2 + scrolltop;
	        obj.css({left: objLeft + 'px', top: objTop + 'px'});
	    });
	    
	    
	}
	
	$("#search2").on("click",function(){
		getSearchByCategory();
	});
	
	
	function getSearchByCategory(){
		var choose_date = $("#config-demo3").val();
		var stationForCategory =  $("#stationForCategory").val();
		var platform_code = $("#platform_code3").val();
		$.ajax({
			url : '${request.contextPath}/searchStatistic/keyForCategoryAjaxData',
			type : "POST",
			data : {
				// choose_date:choose_date,
                beginDate:choose_date.split("-")[0]+" 00:00:00",
                endDate:choose_date.split("-")[1]+" 23:59:59",
				platformCode:platform_code,
				stationId:stationForCategory
			},
			beforeSend: function(){
 			   $("#search2").attr("disabled",true);
 			   openPartialLayer($("#statistical-chart2"));
	    	 },
		    complete: function(){
		    	$("#search2").attr("disabled",false);
		    	removeLoading($("#statistical-chart2"));
		    },
			success:function(data){
			    if (data.code != 0){
			        return;
				}
			    var data = data.data;
				var defs = {
						'category': {
							alias : '品类'
						},
						'amount': {
							alias :'次数（次）'
						},
						'time':{
							type: 'time',
							tickCount: 8
						}
					}; 
				var chart = histogramModal(data.keyCategoryData,'statistical-chart2','category','amount','品类','次数（次）','400',defs);
				if(data.keyCategoryData != "" && data.keyCategoryData != null){
			      chart.on('plotclick',function(ev){
					  var data = ev.data;
					  if (data) {
					    var name = data._origin['category'];
					    var value = data._origin['amount'];
					    getDataByKeyword(name,value);
					  }
					});
					$("#statistical-chart2").css("cursor","pointer");
					var dataFirst = chart.getAllGeoms()[0].getData()[0];
					$("#searchKeyDetail").show();
					$("#productDetail").hide();
					getDataByKeyword(dataFirst._origin['category'],dataFirst._origin['amount']);
			    }else{
			    	$("#searchKeyDetail").hide();
					$("#productDetail").hide();
			    }
			},
			error:function(data) {
				//showMsg("查询数据有误");
			}
		});
	}
	
	function getDataByKeyword(category_name,value){
		var choose_date = $("#config-demo3").val();
		var stationForCategory =  $("#stationForCategory").val();
		var platform_code = $("#platform_code3").val();
		$("#categoryName").html(category_name);
		$("#seachNum").html(value);
		$(".dateSection").html(choose_date)
		var currentPage = $("#currentPage2").val();
		var page_size = $("#page_size2").val();
		$.ajax({
			url : '${request.contextPath}/searchStatistic/keyForKeyWordAjaxData',
			type : "POST",
			data : {
				// choose_date:choose_date,
                beginDate:choose_date.split("-")[0]+" 00:00:00",
                endDate:choose_date.split("-")[1]+" 23:59:59",
				platformCode:platform_code,
				stationId:stationForCategory,
				categoryName:category_name
			},
			beforeSend: function(){
 			   openPartialLayer($("#place-chart2"));
	    	 },
		    complete: function(){
		    	removeLoading($("#place-chart2"));
		    },
			success:function(data) {
                if (data.code != 0){
                    return;
                }
                var data = data.data;
				var defs = {
						'category': {
							alias : '关键词'
						},
						'amount': {
							alias :'搜索次数（次）'
						}
					}; 
  			    var chart = horizontalHistogramModal(data.keyWordData,'place-chart2','category','amount','450',defs);
				if(data.keyWordData != "" && data.keyWordData != null){
			      chart.on('plotclick',function(ev){
					  var data = ev.data;
					  if (data) {
					    var name = data._origin['category'];
					    var value = data._origin['amount'];
					    $("#keyword").val(name);
				        $("#keyword_value").val(value);
						getSearchByKey(name,value,category_name,1,page_size);
					  }
					});
					$("#place-chart2").css("cursor","pointer");
					var dataFirst = chart.getAllGeoms()[0].getData()[0];
					$("#productDetail").show();
				    getSearchByKey(dataFirst._origin['category'],dataFirst._origin['amount'],category_name,1,page_size);
			    }else{
			    	$("#productDetail").hide();
			    }
			},
			error:function(data) {
				//showMsg("查询数据有误");
			}
		});
	}
	
	function changeFlag2(obj){
		var sortName = $(obj).attr("class");
		var flag = $("#flag2").val();
		var num;
		if(sortName == "sorting" || sortName == "sorting_asc"){
			$("#productDetail .dataTable th").eq(2).attr("class","sorting_desc");
			num = 2;//降序
		}else if(sortName == "sorting_desc"){
			$("#productDetail .dataTable th").eq(2).attr("class","sorting_asc");
			num = 1;
		}
		if(num != flag){
			$("#flag2").val(num);
			var keyword = $("#keyword").val();
	        var keyword_value = $("#keyword_value").val();
			var page_size=$("#page_size2").val();
			var category_name = $("#categoryName").html();
			getSearchByKey(keyword,keyword_value,category_name,1,page_size)
		}
	}
	
	function getSearchByKey(keyWord,value,category_name,currentPage,page_size){
	    if(page_size == null || page_size == 'undefined'||currentPage == null || currentPage == 'undefined'){
	    	 currentPage = $("#currentPage2").val();
		     page_size = $("#page_size2").val();
	    }
	    var flag = $("#flag2").val();
		var choose_date = $("#config-demo3").val();
		var stationForCategory =  $("#stationForCategory").val();
		var platform_code = $("#platform_code3").val();
		$(".dateSection").html(choose_date)
		$("#keywordNum").html("关键词："+ keyWord+ "   产品数量 "+value);
		$.ajax({
			url : '${request.contextPath}/searchStatistic/keyForXgWordAjaxData',
			type : "POST",
			data : {
				// choose_date:choose_date,
                beginDate:choose_date.split("-")[0]+" 00:00:00",
                endDate:choose_date.split("-")[1]+" 23:59:59",
				platformCode:platform_code,
				stationId:stationForCategory,
				keyWord:keyWord,
				categoryName:category_name,
				pageCurrentNum:currentPage,
				pageSize:page_size,
				flag:flag
			},
			beforeSend: function(){
 			   openPartialLayer($(".pointTabForCategory"));
	    	 },
		    complete: function(){
		    	removeLoading($(".pointTabForCategory"));
		    },
			success:function(data) {
                if (data.code != 0){
                    return;
                }
                var page = data.data;
				// var page=data.page;
			    if(page.pages>1){
			    	$("#page_total2").val(page.pages);
			    	$("#currentPage2").val(page.pageNum);
			    	$("#page_num2").val(page.pageNum);
			    	$("#sp_1_grid-pager2")[0].innerText=page.pages;
			    	$("#view_start_row2")[0].innerText= page.startRow;
			    	$("#view_end_row2")[0].innerText= page.endRow;
			    	$("#view_page_total2")[0].innerText= page.total;
			    	$(".ui-jqgrid2").show();
			    }else{
			    	$(".ui-jqgrid2").hide();
			    }
				if(page&&page.list&&page.list !=""){
			  		var tbody = "";
			   		$.each(page.list,function(n,value) {
		   		       tbody +=  "<tr>"+
								"<td>"+ value.productId +"</td>"+
								"<td><small>"+value.productName +"</small></td>"+
								"<td class='hidden-480'> <span class='label label-info arrowed-right arrowed-in'>"+ value.productNum+"</span></td>"+
							"</tr>"; 
			       });
			   }else{
			   		var tbody='<tr><td colspan="12"><div class="alert alert-danger" style="margin-bottom: 0px;" role="alert">没有记录!</div></td></tr>';
			   }
			    $(".pointTabForCategory").html(tbody); 
			},
			error:function(data) {
				showMsg("查询数据有误");
			}
		});
	}
	
	function changeTab(id){
   		if(id == 1){
   			$("#keywordDiv1").show();
   			$("#keywordDiv2").hide();
   			 getSearchDate();
   			 var currentPage=1;//当前页面
			 var page_size=$("#page_size").val();//页面大小10条
			 getSearchkeyWord(currentPage,page_size);
   		}else{
   			$("#keywordDiv2").show();
   			$("#keywordDiv1").hide();
   			getSearchByCategory();
   		}
   }  
   
   function showPage(param) {
         var endrow = parseInt($("#sp_1_grid-pager")[0].innerText);
        var currentPage = parseInt($("#currentPage").val());
        var page_size = $("#page_size").val();
		var flag = 0;
		if('firstPage'==param) {
			currentPage =1;
		}
		else if('prePage'==param) {
			if(currentPage==1){
				currentPage ==1;
				flag = 1;
			}else{
				currentPage = currentPage-1;
			}
		}
		else if('nextPage'==param) {
			if(currentPage==endrow){
				currentPage = endrow;
				flag = 1;
			}else{
				currentPage = currentPage+1;
			}
		} else if('lastPage'==param) {
			currentPage = endrow; 
		}
		if(flag==0){
			getSearchkeyWord(currentPage,page_size);
		 }
	}
	
	
  function showPage2(param) {
        var endrow = parseInt($("#sp_1_grid-pager2")[0].innerText);
        var currentPage = parseInt($("#currentPage2").val());
        var page_size = $("#page_size2").val();
		var flag = 0;
		if('firstPage'==param) {
			currentPage =1;
		} else if('prePage'==param) {
			if(currentPage==1){
				currentPage ==1;
				flag = 1;
			}else{
				currentPage = currentPage-1;
			}
		} else if('nextPage'==param) {
			if(currentPage==endrow){
				currentPage = endrow;
				flag = 1;
			}else{
				currentPage = currentPage+1;
			}
		} else if('lastPage'==param) {
			currentPage = endrow; 
		}
		if(flag==0){
			var keyword = $("#keyword").val();
	        var keyword_value = $("#keyword_value").val();
	        var category_name = $("#categoryName").html();
			getSearchByKey(keyword,keyword_value,category_name,currentPage,page_size);
		}
	}
	
	
	//导出图表
/*	function exportCsv2(type){
		var choose_date = $("#config-demo").val();
		var platform_code = $("#platform_code").val();
		var station_id =  $("#station_id").val();
		$.ajax({
			url : '${request.contextPath}/searchStatistic/keyAjaxData',
			type : "POST",
			data : {
				choose_date:choose_date,
				platform_code:platform_code,
				station_id:station_id
			},
			beforeSend: function(){
				if(type=="1"){
 			   		$("#exportDetailKeywordTrend").attr("disabled",true);
 			   	}else{
 			   		$("#exportDetailKeywordStatistic").attr("disabled",true);
 			   	}
 			   
	    	 },
		    complete: function(){
		    	if(type=="1"){
 			   		$("#exportDetailKeywordTrend").attr("disabled",false);
 			   	}else{
 			   		$("#exportDetailKeywordStatistic").attr("disabled",false);
 			   	}
		    },
			success:function(data) {
				if(type=="1"){
					var exportData=data.lineData;
					var compare = function(a, b) {
        					if(a.category != b.category){
								return a.category > b.category ? 1 : -1;
							}else{
								return a.time > b.time ? 1 : -1;
							}
    					}
    				exportData = exportData.sort(compare);
					var exportContent="\uFEFF关键词类型,时间,点击量\n";
					for(var i=0;i<exportData.length;i++){
						exportContent += exportData[i].category+","+exportData[i].time+","+exportData[i].amount+"\n";
					} 
					var blob = new Blob([exportContent],{type: "text/plain;charset=utf-8"});
	        		saveAs(blob, "关键词类型点击量趋势.csv");
				}else{
					var exportData=data.barData;
					var exportContent="\uFEFF关键词类型,点击量\n";
					for(var i=0;i<exportData.length;i++){
						exportContent += exportData[i].category+","+exportData[i].amount+"\n";
					} 
					var blob = new Blob([exportContent],{type: "text/plain;charset=utf-8"});
	        		saveAs(blob, "关键词类型点击量统计.csv");
				}
			}
		});
	
	}*/

	//导出图表
/*	function exportKeywordAnalasys(type){
		var choose_date = $("#config-demo2").val();
		var stationForKey =  $("#stationForKey").val();
		var key_word=$(".keyWordName").html();
		var obj=document.getElementsByName('searchSetion'); //返回数组 
		var sectionIds=''; 
		for(var i=0; i<obj.length; i++){ 
			if(obj[i].checked) 
			  sectionIds+=obj[i].value+','; //如果选中，将value添加到变量sectionIds中 
		} 
		$.ajax({
			url : '${request.contextPath}/searchStatistic/typeAStationAjaxData',
			type : "POST",
			data : {
				choose_date:choose_date,
				sectionIds:sectionIds,
				stationForKey:stationForKey,
				key_word:key_word
			},
			beforeSend: function(){
				if(type=="1"){
 			   		$("#exportDetailKeywordType").attr("disabled",true);
 			   	}else{
 			   		$("#exportDetailTop10").attr("disabled",true);
 			   	}
	    	 },
		    complete: function(){
				if(type=="1"){
 			   		$("#exportDetailKeywordType").attr("disabled",false);
 			   	}else{
 			   		$("#exportDetailTop10").attr("disabled",false);
 			   	}
		    },
			success:function(data) {
				if(type=="1"){
					var exportData=data.keyData;
					var exportContent="\uFEFF关键词类型,点击量\n";
					for(var i=0;i<exportData.length;i++){
						exportContent += exportData[i].category+","+exportData[i].amount+"\n";
					} 
					var blob = new Blob([exportContent],{type: "text/plain;charset=utf-8"});
	        		saveAs(blob, "关键词类型分布.csv");
				}else{
					var exportData=data.stationData;
					var exportContent="\uFEFF地区,点击量\n";
					for(var i=0;i<exportData.length;i++){
						exportContent += exportData[i].category+","+exportData[i].amount+"\n";
					} 
					var blob = new Blob([exportContent],{type: "text/plain;charset=utf-8"});
	        		saveAs(blob, "用户所在地区前十.csv");
				}
			}
		});
	
	}*/
 </script>
</body>
</html>